const { selectAll, deleteStud } = require("../dao/table");
const { log } = require("console");
module.exports = {
  initPage(req, res) {
    selectAll("", function (err, data) {
      if (data.length > 0) {
        let queryData = JSON.stringify(data);
        queryData = queryData.replace(/s_id/g, "学号");
        queryData = queryData.replace(/s_name/g, "姓名");
        queryData = queryData.replace(/s_sex/g, "性别");
        queryData = queryData.replace(/s_age/g, "年龄");
        queryData = queryData.replace(/s_date/g, "出生日期");
        res.send(JSON.parse(queryData));
      }
    });
  },
  delStud(req, res) {
    let { stuId } = req.query;
    deleteStud(stuId, function (err, data) {
      console.log(data);
      if (data) {
        res.send("1");
      } else {
        d;

        3;
        res.send("0");
      }
    });
  },
};
